// 导入变量和混合
@import './variables.scss';
@import './mixins.scss';

// 导入第三方库样式
@import 'nprogress/nprogress.css';

// 重置样式
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 37.5px; // 1rem = 37.5px，基于375px设计稿
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  font-family: $font-family-base;
  font-size: $font-size-base;
  line-height: $line-height-base;
  color: $text-color;
  background-color: $background-color;
  -webkit-overflow-scrolling: touch;
  
  // 禁用选择
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  
  // 禁用长按菜单
  -webkit-touch-callout: none;
}

// 链接样式
a {
  color: $primary-color;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  
  &:hover,
  &:active {
    color: $primary-color-dark;
  }
}

// 按钮样式重置
button {
  border: none;
  outline: none;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

// 输入框样式重置
input,
textarea,
select {
  border: none;
  outline: none;
  font: inherit;
  background: transparent;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  
  &:focus {
    outline: none;
  }
}

// 图片样式
img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

// 列表样式重置
ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

// 标题样式重置
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: normal;
}

// 段落样式重置
p {
  margin: 0;
}

// 滚动条样式
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 2px;
  
  &:hover {
    background: rgba(0, 0, 0, 0.3);
  }
}

// 通用工具类
.clearfix {
  @include clearfix;
}

.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

.text-ellipsis {
  @include text-ellipsis;
}

.text-ellipsis-2 {
  @include text-ellipsis(2);
}

.text-ellipsis-3 {
  @include text-ellipsis(3);
}

// 显示/隐藏
.show {
  display: block !important;
}

.hide {
  display: none !important;
}

.invisible {
  visibility: hidden;
}

.visible {
  visibility: visible;
}

// 浮动
.float-left {
  float: left;
}

.float-right {
  float: right;
}

.float-none {
  float: none;
}

// 定位
.position-relative {
  position: relative;
}

.position-absolute {
  position: absolute;
}

.position-fixed {
  position: fixed;
}

.position-static {
  position: static;
}

// 边距工具类
@for $i from 0 through 10 {
  .m-#{$i} {
    margin: #{$i * 0.1}rem;
  }
  
  .mt-#{$i} {
    margin-top: #{$i * 0.1}rem;
  }
  
  .mr-#{$i} {
    margin-right: #{$i * 0.1}rem;
  }
  
  .mb-#{$i} {
    margin-bottom: #{$i * 0.1}rem;
  }
  
  .ml-#{$i} {
    margin-left: #{$i * 0.1}rem;
  }
  
  .mx-#{$i} {
    margin-left: #{$i * 0.1}rem;
    margin-right: #{$i * 0.1}rem;
  }
  
  .my-#{$i} {
    margin-top: #{$i * 0.1}rem;
    margin-bottom: #{$i * 0.1}rem;
  }
  
  .p-#{$i} {
    padding: #{$i * 0.1}rem;
  }
  
  .pt-#{$i} {
    padding-top: #{$i * 0.1}rem;
  }
  
  .pr-#{$i} {
    padding-right: #{$i * 0.1}rem;
  }
  
  .pb-#{$i} {
    padding-bottom: #{$i * 0.1}rem;
  }
  
  .pl-#{$i} {
    padding-left: #{$i * 0.1}rem;
  }
  
  .px-#{$i} {
    padding-left: #{$i * 0.1}rem;
    padding-right: #{$i * 0.1}rem;
  }
  
  .py-#{$i} {
    padding-top: #{$i * 0.1}rem;
    padding-bottom: #{$i * 0.1}rem;
  }
}

// 字体大小工具类
.text-xs {
  font-size: $font-size-xs;
}

.text-sm {
  font-size: $font-size-sm;
}

.text-base {
  font-size: $font-size-base;
}

.text-lg {
  font-size: $font-size-lg;
}

.text-xl {
  font-size: $font-size-xl;
}

.text-2xl {
  font-size: $font-size-2xl;
}

// 字体粗细
.font-thin {
  font-weight: 100;
}

.font-light {
  font-weight: 300;
}

.font-normal {
  font-weight: 400;
}

.font-medium {
  font-weight: 500;
}

.font-semibold {
  font-weight: 600;
}

.font-bold {
  font-weight: 700;
}

// 颜色工具类
.text-primary {
  color: $primary-color;
}

.text-success {
  color: $success-color;
}

.text-warning {
  color: $warning-color;
}

.text-danger {
  color: $danger-color;
}

.text-info {
  color: $info-color;
}

.text-muted {
  color: $text-color-light;
}

.text-white {
  color: #fff;
}

.text-black {
  color: #000;
}

// 背景颜色
.bg-primary {
  background-color: $primary-color;
}

.bg-success {
  background-color: $success-color;
}

.bg-warning {
  background-color: $warning-color;
}

.bg-danger {
  background-color: $danger-color;
}

.bg-info {
  background-color: $info-color;
}

.bg-white {
  background-color: #fff;
}

.bg-gray {
  background-color: $gray-100;
}

.bg-transparent {
  background-color: transparent;
}

// Flex布局
.flex {
  display: flex;
}

.inline-flex {
  display: inline-flex;
}

.flex-row {
  flex-direction: row;
}

.flex-col {
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

.flex-nowrap {
  flex-wrap: nowrap;
}

.justify-start {
  justify-content: flex-start;
}

.justify-center {
  justify-content: center;
}

.justify-end {
  justify-content: flex-end;
}

.justify-between {
  justify-content: space-between;
}

.justify-around {
  justify-content: space-around;
}

.items-start {
  align-items: flex-start;
}

.items-center {
  align-items: center;
}

.items-end {
  align-items: flex-end;
}

.items-stretch {
  align-items: stretch;
}

.flex-1 {
  flex: 1;
}

.flex-auto {
  flex: auto;
}

.flex-none {
  flex: none;
}

// 宽度高度
.w-full {
  width: 100%;
}

.h-full {
  height: 100%;
}

.min-h-screen {
  min-height: 100vh;
}

// 圆角
.rounded {
  border-radius: $border-radius-base;
}

.rounded-sm {
  border-radius: $border-radius-sm;
}

.rounded-lg {
  border-radius: $border-radius-lg;
}

.rounded-full {
  border-radius: 50%;
}

.rounded-none {
  border-radius: 0;
}

// 阴影
.shadow {
  box-shadow: $box-shadow-base;
}

.shadow-sm {
  box-shadow: $box-shadow-sm;
}

.shadow-lg {
  box-shadow: $box-shadow-lg;
}

.shadow-none {
  box-shadow: none;
}

// 边框
.border {
  border: 1px solid $border-color;
}

.border-t {
  border-top: 1px solid $border-color;
}

.border-r {
  border-right: 1px solid $border-color;
}

.border-b {
  border-bottom: 1px solid $border-color;
}

.border-l {
  border-left: 1px solid $border-color;
}

.border-none {
  border: none;
}

// 溢出处理
.overflow-hidden {
  overflow: hidden;
}

.overflow-auto {
  overflow: auto;
}

.overflow-scroll {
  overflow: scroll;
}

.overflow-x-hidden {
  overflow-x: hidden;
}

.overflow-y-hidden {
  overflow-y: hidden;
}

.overflow-x-auto {
  overflow-x: auto;
}

.overflow-y-auto {
  overflow-y: auto;
}

// 自定义组件样式
.page {
  min-height: 100vh;
  background-color: $background-color;
}

.page-content {
  padding: 0.4rem;
}

.card {
  background: #fff;
  border-radius: $border-radius-base;
  box-shadow: $box-shadow-sm;
  overflow: hidden;
}

.card-header {
  padding: 0.4rem;
  border-bottom: 1px solid $border-color;
  font-weight: 500;
}

.card-body {
  padding: 0.4rem;
}

.card-footer {
  padding: 0.4rem;
  border-top: 1px solid $border-color;
  background-color: $gray-50;
}

// 动画类
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

.slide-up-enter-active,
.slide-up-leave-active {
  transition: transform 0.3s ease;
}

.slide-up-enter-from,
.slide-up-leave-to {
  transform: translateY(100%);
}

.slide-down-enter-active,
.slide-down-leave-active {
  transition: transform 0.3s ease;
}

.slide-down-enter-from,
.slide-down-leave-to {
  transform: translateY(-100%);
}

.slide-left-enter-active,
.slide-left-leave-active {
  transition: transform 0.3s ease;
}

.slide-left-enter-from,
.slide-left-leave-to {
  transform: translateX(100%);
}

.slide-right-enter-active,
.slide-right-leave-active {
  transition: transform 0.3s ease;
}

.slide-right-enter-from,
.slide-right-leave-to {
  transform: translateX(-100%);
}

// 响应式工具类
@media (max-width: 480px) {
  .hidden-xs {
    display: none !important;
  }
}

@media (min-width: 481px) {
  .visible-xs {
    display: none !important;
  }
}

// 深色主题
[data-theme='dark'] {
  body {
    background-color: #1a1a1a;
    color: #e5e5e5;
  }
  
  .card {
    background: #2a2a2a;
    color: #e5e5e5;
  }
  
  .card-footer {
    background-color: #333;
  }
}

// 安全区域适配
.safe-area-inset-top {
  padding-top: constant(safe-area-inset-top);
  padding-top: env(safe-area-inset-top);
}

.safe-area-inset-bottom {
  padding-bottom: constant(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-bottom);
}

.safe-area-inset-left {
  padding-left: constant(safe-area-inset-left);
  padding-left: env(safe-area-inset-left);
}

.safe-area-inset-right {
  padding-right: constant(safe-area-inset-right);
  padding-right: env(safe-area-inset-right);
}